<?php
namespace app\wx\controller;
use think\Controller;
use think\Request;
use think\config;

 use think\Db;
class Indexof extends Controller
{
   public $token = 'hjkhjk';
    // http://2.mswl.applinzi.com/t3f3/Wx.php/Home/Lianjie/index 原案例
    // http://www.hyhthjk.com.cn/note.php/wx/Indexof/checkSignature 现地址

    /**
     * 验证接口权限
     * 微信传来signature nonce timestamp echostr
     * 验证成功返回给微信echostr
     */
    public function checkSignature()
    {
   
         $signature = input('get.signature');   
         $timestamp = input('get.timestamp');
         $nonce = input('get.nonce');
         $token = 'hjkhjk'; 
         $echostr = input('get.echostr');
        
         $tmpArr = array($token, $timestamp, $nonce);//组成新数组
         sort($tmpArr, SORT_STRING);//重新排序
         $tmpStr =implode('', $tmpArr );//转换成字符串
         $tmpStr = sha1( $tmpStr );  //再将字符串进行加密
         
 
         if( $tmpStr == $signature ){
 
             echo  $echostr;
         }else{
             return 'false';
             
         }
     }
    
    


  
	
}
